<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>简单计算器</title>
<script>
  function getResult() {
    var a = parseFloat(document.calculator.number1.value);
    var b = document.calculator.sign.value;
    var c = parseFloat(document.calculator.number2.value);
    var d = 0;
    switch (b) {
    case '+':
      d = a + c;
      break;
    case '-':
      d = a - c;
      break;
    case '*':
      d = a * c;
      break;
    case '/':
      d = a / c;
      break;
    }
    document.calculator.result.value = d;
  }
</script>
</head>
<body>
  <form name="calculator">
    <label>
      数值1
      <input type="text" name="number1">
    </label>
    <label>
      运算符
      <select name="sign">
        <option>+</option>
        <option>-</option>
        <option>*</option>
        <option>/</option>
      </select>
    </label>
    <label>
      数值2
      <input type="text" name="number2">
    </label>
    <input type="button" name="calculate" value="=" onclick="getResult()">
    <label>
      结果
      <input type="text" name="result" disabled>
    </label>
  </form>
</body>
</html>